package com.itdaan.portal.business.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.itdaan.portal.business.domain.Blog;
import com.itdaan.portal.business.domain.Page;
import com.itdaan.portal.business.mapper.BlogMapper;
import com.itdaan.portal.business.service.BlogService;
import com.itdaan.portal.common.exception.ServiceException;

/**
 * @author www.itdaan.com
 */
@Service(value = "blogService")
public class BlogServiceImpl implements BlogService {

	@Resource(name = "blogMapper")
	private BlogMapper blogMapper;
	
	@Override
	public Blog findPostOne(Integer id) throws ServiceException {
		return blogMapper.selectByPrimaryKey(id);
	}

	@Override
	public List<Blog> findHotest() throws ServiceException {
		return blogMapper.selectHostest();
	}

	@Override
	public List<Blog> findCollectionMore() throws ServiceException {
		return blogMapper.selectCollectionMore();
	}

	@Override
	public List<Blog> findRecommendMore() throws ServiceException {
		return blogMapper.selectRecommendMore();
	}

	@Override
	public Page findBlogPage(Page page) throws ServiceException {
		List<Object> datas = blogMapper.getByPage(page);
		long count = blogMapper.getCountByPage(page);
		page.setDatas(datas);
		page.setCount(count);
		return page;
	}

	
	
}
